package com.yuejie.musicai.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yuejie.musicai.beans.Result;
import com.yuejie.musicai.beans.UrlParsed;
import com.yuejie.musicai.services.impl.ParseUrlServiceImpl;
import com.yuejie.musicai.services.impl.ResultServiceImpl;

/**
 * 播放器相关Controller
 * @author Ocelot
 *
 */
@Controller
public class PlayerController {
	
	@Autowired
	ResultServiceImpl resultservice;
	
	@Autowired
	ParseUrlServiceImpl parseurlservice;
	
	private static final Logger logger = LoggerFactory.getLogger(PlayerController.class);
	
	/**
	 * 返回播放页面
	 * @return
	 */
	@RequestMapping(value = "/player")
	public String player() {
		return "player";
	}
	
	/**
	 * 获取歌曲列表
	 * @param qword
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/resultxml", method=RequestMethod.GET)
	public @ResponseBody Result playlist(@RequestParam String qword, @RequestParam String page) {
		return resultservice.getResult(qword, page);
	}
	
	@RequestMapping(value="/parseurl", method=RequestMethod.GET)
	public @ResponseBody UrlParsed parseurl(@RequestParam String url) {
		return parseurlservice.getUrlXml(url);
	}
	

}
